Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use PyObject_CallMethod in resource loaders #2974

Merged

Conversation

Starbuck5
Copy link
Member

This is a slight simplification from the existing strategy of getting the functions then calling them. The new way has fewer lines of code, and doesn't need to manage the refcount and existence of references to functions, so it is simpler and likely faster.

The resource loaders have way bigger problems-- they are using a deprecated setuptools API, they likely should be reworked to use the replacement API from importlib. I also think they're being over-cautious with handling of file objects, I think they should just hand off directly to rwobject.c instead of faffing around with the .name and trying to close them if they're streams.

This PR doesn't touch that since that would be complex to research and to review. The current change is low hanging fruit but it's worthwhile too.

This is a slight simplification from the existing strategy of getting the functions then calling them. The new way has fewer lines of code, and doesn't need to manage the refcount and existence of references to functions, so it is simpler and likely faster.
@Starbuck5 Starbuck5 added the Code quality/robustness Code quality and resilience to changes label Jul 6, 2024
@Starbuck5 Starbuck5 requested a review from a team as a code owner July 6, 2024 23:19
Copy link
Member

@damusss damusss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically replaced func = self.function;func() with self.function(), makes sense to me 👍

@damusss damusss added this to the 2.5.1 milestone Jul 7, 2024
Copy link
Member

@ankith26 ankith26 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks! 🎉

@ankith26 ankith26 merged commit d3d815e into pygame-community:main Jul 7, 2024
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code quality/robustness Code quality and resilience to changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants